﻿using DotNetExtensions.AspNet.SQLites;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SQLiteSimple
{
    class Program
    {
        static void Main(string[] args)
        {

            int number = Convert.ToInt32("000a1b", 16);
            string str = Convert.ToString(number, 16).PadLeft(6,'0');

            Console.WriteLine(str);

            string connectionString = @"Data Source=d:\test.db;Version=3;";
            SQLiteBuilder.Default.Initialize(SQLiteConnectionFactory.Default.Create(connectionString));

            TestDbContext dbContext = new TestDbContext(connectionString);
            int Id = 2;
            string name = "Jack ma";

            dbContext.UserModel.InsertRange(new List<UserModel> {
            new UserModel { Age = 2, CreateTime = DateTime.Now, Id = 7, Name = "Jack m1" },
            new UserModel { Age = 3, CreateTime = DateTime.Now, Id = 8, Name = "Jack m2" },
            new UserModel { Age = 4, CreateTime = DateTime.Now, Id = 9, Name = "Jack m3" }
            });

            //dbContext.UserModel.Delete(c => c.Id == Id && c.Name == name);
            //dbContext.UserModel.Insert(new UserModel { Age = 12, CreateTime = DateTime.Now, Id = 5, Name = "Jack ma" });
            //dbContext.UserModel.Insert(new UserModel { Age = 12, CreateTime = DateTime.Now, Id = 4, Name = "Jack ma" });
            //dbContext.AccountModel.Insert(new AccountModel { Id=1, LastChange =DateTime.Now, Money = 128.8, UserId = 2 });
            //var first = dbContext.UserModel.GetSingle(c=>c.Id == 4);
            //first.Name = "Jack chen4";
            //dbContext.UserModel.UpdateBy(first, c => new { c.Id, c.Age });

            var users = dbContext.UserModel.Get().ToList();
            Console.ReadKey();
        }
    }
}
